home *** CD-ROM | disk | FTP | other *** search
-
- /*⌐ Copyright 1988-1991 UserLand Software, Inc. All Rights Reserved.*/
-
-
- #include "appletinternal.h"
- #include "ops.h"
- #include "font.h"
-
-
- #define styleseparator "\p+"
-
- FontInfo globalfontinfo;
-
-
-
- void setfontsizestyle (short fontnum, short fontsize, short fontstyle) {
-
- TextFont (fontnum);
-
- TextSize (fontsize);
-
- TextFace (fontstyle);
- } /*setfontsizestyle*/
-
-
- void setglobalfontsizestyle (short fontnum, short fontsize, short fontstyle) {
-
- setfontsizestyle (fontnum, fontsize, fontstyle);
-
- GetFontInfo (&globalfontinfo);
- } /*setglobalfontsizestyle*/
-
-
- short setnamedfont (bigstring bs, short fsize, short fstyle, short defaultfont) {
-
- /*
- give me the name of a font you like. I'll try to set to that font,
- but if its not available, you get the default font. be sure to select
- a default font that is mandatory -- like geneva or newYork.
- */
-
- short fontnum;
-
- GetFNum (bs, &fontnum);
-
- if (fontnum == 0)
- fontnum = defaultfont; /*use caller's second choice*/
-
- setglobalfontsizestyle (fontnum, fsize, fstyle);
-
- return (fontnum); /*return the font that we are actually using*/
- } /*setnamedfont*/
-
-
- void getfontsizestyle (short *fontnum, short *fontsize, short *fontstyle) {
-
- *fontnum = (*quickdrawglobal (thePort)).txFont;
-
- *fontsize = (*quickdrawglobal (thePort)).txSize;
-
- *fontstyle = (*quickdrawglobal (thePort)).txFace;
- } /*getfontsizestyle*/
-
-
- void fontstring (short fontnum, short fontsize, boolean flhavefont, boolean flhavesize, bigstring bs) {
-
- bigstring bsint;
-
- bs [0] = (char) 0; /*set it to the empty string*/
-
- if (flhavefont)
- GetFontName (fontnum, bs);
-
- if (flhavesize) {
-
- NumToString (fontsize, bsint);
-
- if (flhavefont) {
-
- pushspace (bs);
-
- pushstring (bsint, bs);
- }
- else
- copystring ("\pno consistent font", bs);
- }
- } /*fontstring*/
-
-
- void getstyle (short style, short *flplain, short *flbold, short *flitalic, short *flunderline, short *floutline, short *flshadow) {
-
- /*
- give me a style bit array, and I'll extract the booleans which are
- slightly easier to deal with.
-
- if none of the others are true, we set flplain to true. otherwise
- flplain is false.
- */
-
- *flplain = true; /*default values*/
-
- *flbold = false;
-
- *flitalic = false;
-
- *flunderline = false;
-
- *floutline = false;
-
- *flshadow = false;
-
- if (style >= shadow) {
-
- style -= shadow;
-
- *flshadow = true;
-
- *flplain = false;
- }
-
- if (style >= outline) {
-
- style -= outline;
-
- *floutline = true;
-
- *flplain = false;
- }
-
- if (style >= underline) {
-
- style -= underline;
-
- *flunderline = true;
-
- *flplain = false;
- }
-
- if (style >= italic) {
-
- style -= italic;
-
- *flitalic = true;
-
- *flplain = false;
- }
-
- if (style >= bold) {
-
- style -= bold;
-
- *flbold = true;
-
- *flplain = false;
- }
- } /*getstyle*/
-
-
- void checkstyle (boolean fl, bigstring bsin, bigstring bsout) {
-
- if (fl) {
- if (bsout [0]) { /*already something on the output string*/
-
- pushstring (styleseparator, bsout);
-
- pushstring (bsin, bsout);
- }
- else
- copystring (bsin, bsout);
- }
- } /*checkstyle*/
-
-
- short getfontheight (void) {
-
- FontInfo info;
-
- GetFontInfo (&info);
-
- return (info.ascent + info.descent);
- } /*getfontheight*/
-
-
-